-- ----------------------------
-- Table structure for trace_code
-- ----------------------------
DROP TABLE IF EXISTS trace_code;

CREATE TABLE trace_code
(
    code_id     BIGINT        NOT NULL DEFAULT nextval('trace_code_code_id_seq'::regclass),
    sellpro_id  BIGINT        NOT NULL DEFAULT 0,
    version_id  BIGINT        NOT NULL DEFAULT 0,
    trace_code  VARCHAR(500)  NOT NULL DEFAULT '',
    trace_url   VARCHAR(500)  NOT NULL DEFAULT '',
    remark      VARCHAR(2000) NOT NULL DEFAULT '',
    status      CHAR(1)       NOT NULL DEFAULT '2',
    order_num   INTEGER       NOT NULL DEFAULT 0,
    create_by   BIGINT        NOT NULL DEFAULT 0,
    create_time TIMESTAMP,
    update_by   BIGINT                 DEFAULT 0,
    update_time TIMESTAMP,
    del_flag    CHAR(1)       NOT NULL DEFAULT '0',
    PRIMARY KEY (code_id)
);

-- 创建序列用于自动递增
CREATE SEQUENCE trace_code_code_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

-- 添加注释
COMMENT ON TABLE trace_code IS '溯源码表';
COMMENT ON COLUMN trace_code.code_id IS '溯源码ID';
COMMENT ON COLUMN trace_code.sellpro_id IS '产品ID';
COMMENT ON COLUMN trace_code.version_id IS '溯源版本ID';
COMMENT ON COLUMN trace_code.trace_code IS '溯源码';
COMMENT ON COLUMN trace_code.trace_url IS '溯源链接';
COMMENT ON COLUMN trace_code.remark IS '备注';
COMMENT ON COLUMN trace_code.status IS '状态 1可用 2不可用 trace_status';
COMMENT ON COLUMN trace_code.order_num IS '排序';
COMMENT ON COLUMN trace_code.create_by IS '创建者ID';
COMMENT ON COLUMN trace_code.create_time IS '创建时间';
COMMENT ON COLUMN trace_code.update_by IS '修改人ID';
COMMENT ON COLUMN trace_code.update_time IS '修改时间';
COMMENT ON COLUMN trace_code.del_flag IS '删除标志（0代表存在 2代表删除）';

-- ----------------------------
-- Table structure for trace_code_template
-- ----------------------------
DROP TABLE IF EXISTS trace_code_template;

CREATE TABLE trace_code_template
(
    template_id     BIGINT        NOT NULL DEFAULT nextval('trace_code_template_template_id_seq'::regclass),
    template_name   VARCHAR(255)  NOT NULL DEFAULT '',
    template_bgi    VARCHAR(100)  NOT NULL DEFAULT '',
    template_width  INTEGER       NOT NULL DEFAULT 0,
    template_height INTEGER       NOT NULL DEFAULT 0,
    qrcode_width    INTEGER       NOT NULL DEFAULT 0,
    qrcode_height   INTEGER       NOT NULL DEFAULT 0,
    qrcode_x        INTEGER       NOT NULL DEFAULT 0,
    qrcode_y        INTEGER       NOT NULL DEFAULT 0,
    remark          VARCHAR(2000) NOT NULL DEFAULT '',
    status          CHAR(1)       NOT NULL DEFAULT '0',
    order_num       INTEGER       NOT NULL DEFAULT 0,
    create_by       BIGINT        NOT NULL DEFAULT 0,
    create_time     TIMESTAMP,
    update_by       BIGINT                 DEFAULT 0,
    update_time     TIMESTAMP,
    del_flag        CHAR(1)       NOT NULL DEFAULT '0',
    tenant_id       BIGINT        NOT NULL DEFAULT 0,
    base_id         BIGINT        NOT NULL DEFAULT 0,
    create_dept        int8,
    user_id         BIGINT        NOT NULL DEFAULT 0,
    PRIMARY KEY (template_id)
);


-- 创建序列用于自动递增
CREATE SEQUENCE trace_code_template_template_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

-- 添加注释
COMMENT ON TABLE trace_code_template IS '溯源码模版表';
COMMENT ON COLUMN trace_code_template.template_id IS '模版ID';
COMMENT ON COLUMN trace_code_template.template_name IS '模版名称';
COMMENT ON COLUMN trace_code_template.template_bgi IS '模版背景图';
COMMENT ON COLUMN trace_code_template.template_width IS '模版宽度(PX)';
COMMENT ON COLUMN trace_code_template.template_height IS '模版高度(PX)';
COMMENT ON COLUMN trace_code_template.qrcode_width IS '二维码宽度(PX)';
COMMENT ON COLUMN trace_code_template.qrcode_height IS '二维码高度(PX)';
COMMENT ON COLUMN trace_code_template.qrcode_x IS '二维码横坐标位置(PX)';
COMMENT ON COLUMN trace_code_template.qrcode_y IS '二维码纵坐标位置(PX)';
COMMENT ON COLUMN trace_code_template.remark IS '备注';
COMMENT ON COLUMN trace_code_template.status IS '状态（0可用，2不可用）';
COMMENT ON COLUMN trace_code_template.order_num IS '排序';
COMMENT ON COLUMN trace_code_template.create_by IS '创建者ID';
COMMENT ON COLUMN trace_code_template.create_time IS '创建时间';
COMMENT ON COLUMN trace_code_template.update_by IS '修改人ID';
COMMENT ON COLUMN trace_code_template.update_time IS '修改时间';
COMMENT ON COLUMN trace_code_template.del_flag IS '删除标志（0代表存在 2代表删除）';
COMMENT ON COLUMN trace_code_template.tenant_id IS '租户ID';
COMMENT ON COLUMN trace_code_template.base_id IS '基地ID';
COMMENT ON COLUMN trace_code_template.create_dept IS '部门ID';
COMMENT ON COLUMN trace_code_template.user_id IS '用户ID';

-- ----------------------------
-- Table structure for trace_record
-- ----------------------------
DROP TABLE IF EXISTS trace_record;

CREATE TABLE trace_record
(
    record_id        BIGINT        NOT NULL DEFAULT nextval('trace_record_record_id_seq'::regclass),
    sellpro_id       BIGINT        NOT NULL DEFAULT 0,
    trace_code       VARCHAR(500)  NOT NULL DEFAULT '',
    query_date       TIMESTAMP,
    query_address    VARCHAR(50)   NOT NULL DEFAULT '',
    query_coordinate VARCHAR(50)   NOT NULL DEFAULT '',
    query_city       VARCHAR(50)   NOT NULL DEFAULT '',
    city_code        VARCHAR(50)   NOT NULL DEFAULT '',
    remark           VARCHAR(2000) NOT NULL DEFAULT '',
    status           CHAR(1)       NOT NULL DEFAULT '2',
    order_num        INTEGER       NOT NULL DEFAULT 0,
    create_by        BIGINT        NOT NULL DEFAULT 0,
    create_time      TIMESTAMP,
    update_by        BIGINT                 DEFAULT 0,
    update_time      TIMESTAMP,
    del_flag         CHAR(1)       NOT NULL DEFAULT '0',
    PRIMARY KEY (record_id)
);


-- 创建序列用于自动递增
CREATE SEQUENCE trace_record_record_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

-- 添加注释
COMMENT ON TABLE trace_record IS '溯源码查询记录表';
COMMENT ON COLUMN trace_record.record_id IS '记录ID';
COMMENT ON COLUMN trace_record.sellpro_id IS '产品ID';
COMMENT ON COLUMN trace_record.trace_code IS '溯源码';
COMMENT ON COLUMN trace_record.query_date IS '查询时间';
COMMENT ON COLUMN trace_record.query_address IS '查询地点';
COMMENT ON COLUMN trace_record.query_coordinate IS '查询坐标';
COMMENT ON COLUMN trace_record.query_city IS '查询城市';
COMMENT ON COLUMN trace_record.city_code IS '城市代码';
COMMENT ON COLUMN trace_record.remark IS '备注';
COMMENT ON COLUMN trace_record.status IS '状态';
COMMENT ON COLUMN trace_record.order_num IS '排序';
COMMENT ON COLUMN trace_record.create_by IS '创建者ID';
COMMENT ON COLUMN trace_record.create_time IS '创建时间';
COMMENT ON COLUMN trace_record.update_by IS '修改人ID';
COMMENT ON COLUMN trace_record.update_time IS '修改时间';
COMMENT ON COLUMN trace_record.del_flag IS '删除标志（0代表存在 2代表删除）';


-- ----------------------------
-- Table structure for trace_sellpro
-- ----------------------------
DROP TABLE IF EXISTS trace_sellpro;

CREATE TABLE trace_sellpro
(
    sellpro_id       BIGINT        NOT NULL DEFAULT nextval('trace_sellpro_sellpro_id_seq'::regclass),
    sellpro_name     VARCHAR(20)   NOT NULL DEFAULT '',
    sellpro_area     VARCHAR(20)   NOT NULL DEFAULT '',
    sellpro_weight   VARCHAR(20)   NOT NULL DEFAULT '',
    sellpro_guige    VARCHAR(20)   NOT NULL DEFAULT '',
    sellpro_img      VARCHAR(500)  NOT NULL DEFAULT '',
    template_id      INTEGER,
    code_template_id BIGINT,
    germplasm_id     VARCHAR(100)  NOT NULL DEFAULT '',
    batch_id         VARCHAR(100)  NOT NULL DEFAULT '',
    land_id          VARCHAR(100)  NOT NULL DEFAULT '',
    device_id        VARCHAR(100)  NOT NULL DEFAULT '',
    camera_id        VARCHAR(100)  NOT NULL DEFAULT '',
    staff_id         VARCHAR(100)  NOT NULL DEFAULT '',
    shop_id          VARCHAR(100)  NOT NULL DEFAULT '',
    h5_url           VARCHAR(500)  NOT NULL DEFAULT '',
    remark           VARCHAR(2000) NOT NULL DEFAULT '',
    status           CHAR(1)       NOT NULL DEFAULT '2',
    order_num        INTEGER       NOT NULL DEFAULT 0,
    create_by        BIGINT        NOT NULL DEFAULT 0,
    create_time      TIMESTAMP,
    update_by        BIGINT                 DEFAULT 0,
    update_time      TIMESTAMP,
    del_flag         CHAR(1)       NOT NULL DEFAULT '0',
    tenant_id        BIGINT        NOT NULL DEFAULT 0,
    base_id          BIGINT        NOT NULL DEFAULT 0,
    create_dept        int8,
    user_id          BIGINT        NOT NULL DEFAULT 0,
    PRIMARY KEY (sellpro_id)
);


-- 创建序列用于自动递增
CREATE SEQUENCE trace_sellpro_sellpro_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

-- 添加注释
COMMENT ON TABLE trace_sellpro IS '溯源产品表';
COMMENT ON COLUMN trace_sellpro.sellpro_id IS '产品ID';
COMMENT ON COLUMN trace_sellpro.sellpro_name IS '产品名称';
COMMENT ON COLUMN trace_sellpro.sellpro_area IS '产地';
COMMENT ON COLUMN trace_sellpro.sellpro_weight IS '产品重量';
COMMENT ON COLUMN trace_sellpro.sellpro_guige IS '产品规格';
COMMENT ON COLUMN trace_sellpro.sellpro_img IS '产品图片';
COMMENT ON COLUMN trace_sellpro.template_id IS '溯源页面模版ID';
COMMENT ON COLUMN trace_sellpro.code_template_id IS '溯源码模版ID';
COMMENT ON COLUMN trace_sellpro.germplasm_id IS '种质ID';
COMMENT ON COLUMN trace_sellpro.batch_id IS '批次ID';
COMMENT ON COLUMN trace_sellpro.land_id IS '地块ID';
COMMENT ON COLUMN trace_sellpro.device_id IS '环境设备ID';
COMMENT ON COLUMN trace_sellpro.camera_id IS '监控设备ID';
COMMENT ON COLUMN trace_sellpro.staff_id IS '溯源人员ID';
COMMENT ON COLUMN trace_sellpro.shop_id IS '店铺ID';
COMMENT ON COLUMN trace_sellpro.h5_url IS '溯源页面';
COMMENT ON COLUMN trace_sellpro.remark IS '备注';
COMMENT ON COLUMN trace_sellpro.status IS '状态 1可用 2不可用 trace_status';
COMMENT ON COLUMN trace_sellpro.order_num IS '排序';
COMMENT ON COLUMN trace_sellpro.create_by IS '创建者ID';
COMMENT ON COLUMN trace_sellpro.create_time IS '创建时间';
COMMENT ON COLUMN trace_sellpro.update_by IS '修改人ID';
COMMENT ON COLUMN trace_sellpro.update_time IS '修改时间';
COMMENT ON COLUMN trace_sellpro.del_flag IS '删除标志（0代表存在 2代表删除）';
COMMENT ON COLUMN trace_sellpro.tenant_id IS '租户ID';
COMMENT ON COLUMN trace_sellpro.base_id IS '基地ID';
COMMENT ON COLUMN trace_sellpro.create_dept IS '部门ID';
COMMENT ON COLUMN trace_sellpro.user_id IS '用户ID';


-- ----------------------------
-- Table structure for trace_shop
-- ----------------------------
DROP TABLE IF EXISTS trace_shop;

CREATE TABLE trace_shop
(
    shop_id         BIGINT        NOT NULL DEFAULT nextval('trace_shop_shop_id_seq'::regclass),
    shop_name       VARCHAR(50)   NOT NULL DEFAULT '',
    shop_type       VARCHAR(20)   NOT NULL DEFAULT '0',
    shop_img        VARCHAR(250)  NOT NULL DEFAULT '',
    shop_address    VARCHAR(50)   NOT NULL DEFAULT '',
    shop_coordinate VARCHAR(50)   NOT NULL DEFAULT '',
    shop_contacts   VARCHAR(20)   NOT NULL DEFAULT '',
    shop_tel        VARCHAR(20)   NOT NULL DEFAULT '',
    shop_url        VARCHAR(2000) NOT NULL DEFAULT '',
    shop_des        VARCHAR(100)  NOT NULL DEFAULT '',
    remark          VARCHAR(2000) NOT NULL DEFAULT '',
    status          CHAR(1)       NOT NULL DEFAULT '2',
    order_num       INTEGER       NOT NULL DEFAULT 0,
    create_by       BIGINT        NOT NULL DEFAULT 0,
    create_time     TIMESTAMP,
    update_by       BIGINT                 DEFAULT 0,
    update_time     TIMESTAMP,
    del_flag        CHAR(1)       NOT NULL DEFAULT '0',
    tenant_id       BIGINT        NOT NULL DEFAULT 0,
    base_id         BIGINT        NOT NULL DEFAULT 0,
    create_dept        int8,
    user_id         BIGINT        NOT NULL DEFAULT 0,
    PRIMARY KEY (shop_id)
);


-- 创建序列用于自动递增
CREATE SEQUENCE trace_shop_shop_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

-- 添加注释
COMMENT ON TABLE trace_shop IS '店铺表';
COMMENT ON COLUMN trace_shop.shop_id IS '店铺ID';
COMMENT ON COLUMN trace_shop.shop_name IS '店铺名称';
COMMENT ON COLUMN trace_shop.shop_type IS '店铺类型 1线上 2线下';
COMMENT ON COLUMN trace_shop.shop_img IS '店铺图片';
COMMENT ON COLUMN trace_shop.shop_address IS '店铺地址';
COMMENT ON COLUMN trace_shop.shop_coordinate IS '店铺坐标';
COMMENT ON COLUMN trace_shop.shop_contacts IS '店铺联系人';
COMMENT ON COLUMN trace_shop.shop_tel IS '店铺联系方式';
COMMENT ON COLUMN trace_shop.shop_url IS '店铺链接';
COMMENT ON COLUMN trace_shop.shop_des IS '店铺描述';
COMMENT ON COLUMN trace_shop.remark IS '备注';
COMMENT ON COLUMN trace_shop.status IS '状态 1可用 2不可用 trace_status';
COMMENT ON COLUMN trace_shop.order_num IS '排序';
COMMENT ON COLUMN trace_shop.create_by IS '创建者ID';
COMMENT ON COLUMN trace_shop.create_time IS '创建时间';
COMMENT ON COLUMN trace_shop.update_by IS '修改人ID';
COMMENT ON COLUMN trace_shop.update_time IS '修改时间';
COMMENT ON COLUMN trace_shop.del_flag IS '删除标志（0代表存在 2代表删除）';
COMMENT ON COLUMN trace_shop.tenant_id IS '租户ID';
COMMENT ON COLUMN trace_shop.base_id IS '基地ID';
COMMENT ON COLUMN trace_shop.create_dept IS '部门ID';
COMMENT ON COLUMN trace_shop.user_id IS '用户ID';

-- ----------------------------
-- Records of trace_shop
-- ----------------------------
BEGIN;
INSERT INTO trace_shop (shop_id, shop_name, shop_type, shop_img, shop_address, shop_coordinate, shop_contacts, shop_tel, shop_url, shop_des, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag, tenant_id, base_id, create_dept, user_id) VALUES
    (1, '盐城开发区店', '1', '/profile/iot/1/2023-0802-174630.png', '盐城市开发区', '120.139974,33.353455', '乔军', '18112857630', 'https://item.taobao.com/item.htm?id=712366130554&ali_refid=a3_430673_1006:1125303001:N:emtiAWsF8%2Bzhhxaiwzc0Aw%3D%3D:1d8c5875b3f9dba8210ac36019832038&ali_trackid=162_1d8c5875b3f9dba8210ac36019832038&spm=a2e0b.20350158.31919782.2', '这是一个很好的店铺', '111', '0', 0, 1, '2023-08-02 17:49:59', 1, '2024-04-18 16:40:59', '0', 0, 0, 0, 0);
INSERT INTO trace_shop (shop_id, shop_name, shop_type, shop_img, shop_address, shop_coordinate, shop_contacts, shop_tel, shop_url, shop_des, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag, tenant_id, base_id, create_dept, user_id) VALUES
    (2, '姚琼测试点欧', '1', '/profile/iot/10/2024-0822-131629.jpg', '1', '120.142497,33.378343', '乔军', '11111111111', 'baidu.com', 'sdsd', '', '0', 0, 10, '2024-08-22 13:16:52', 0, NULL, '0', 113, 101, 103, 10);
COMMIT;


-- ----------------------------
-- Table structure for trace_staff
-- ----------------------------
DROP TABLE IF EXISTS trace_staff;

CREATE TABLE trace_staff
(
    staff_id       BIGINT        NOT NULL DEFAULT nextval('trace_staff_staff_id_seq'::regclass),
    staff_position VARCHAR(50)   NOT NULL DEFAULT '',
    staff_name     VARCHAR(50)   NOT NULL DEFAULT '',
    staff_tel      VARCHAR(20)   NOT NULL DEFAULT '',
    staff_des      VARCHAR(100)  NOT NULL DEFAULT '',
    remark         VARCHAR(2000) NOT NULL DEFAULT '',
    status         CHAR(1)       NOT NULL DEFAULT '1',
    order_num      INTEGER       NOT NULL DEFAULT 0,
    create_by      BIGINT        NOT NULL DEFAULT 0,
    create_time    TIMESTAMP,
    update_by      BIGINT                 DEFAULT 0,
    update_time    TIMESTAMP,
    del_flag       CHAR(1)       NOT NULL DEFAULT '0',
    tenant_id      BIGINT        NOT NULL DEFAULT 0,
    base_id        BIGINT        NOT NULL DEFAULT 0,
    create_dept        int8,
    user_id        BIGINT        NOT NULL DEFAULT 0,
    PRIMARY KEY (staff_id)
);


-- 创建序列用于自动递增
CREATE SEQUENCE trace_staff_staff_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

-- 添加注释
COMMENT ON TABLE trace_staff IS '溯源人员表';
COMMENT ON COLUMN trace_staff.staff_id IS '员工ID';
COMMENT ON COLUMN trace_staff.staff_position IS '员工职位';
COMMENT ON COLUMN trace_staff.staff_name IS '员工名称';
COMMENT ON COLUMN trace_staff.staff_tel IS '员工联系方式';
COMMENT ON COLUMN trace_staff.staff_des IS '员工描述';
COMMENT ON COLUMN trace_staff.remark IS '备注';
COMMENT ON COLUMN trace_staff.status IS '状态 1可用 2不可用 trace_status';
COMMENT ON COLUMN trace_staff.order_num IS '排序';
COMMENT ON COLUMN trace_staff.create_by IS '创建者ID';
COMMENT ON COLUMN trace_staff.create_time IS '创建时间';
COMMENT ON COLUMN trace_staff.update_by IS '修改人ID';
COMMENT ON COLUMN trace_staff.update_time IS '修改时间';
COMMENT ON COLUMN trace_staff.del_flag IS '删除标志（0代表存在 2代表删除）';
COMMENT ON COLUMN trace_staff.tenant_id IS '租户ID';
COMMENT ON COLUMN trace_staff.base_id IS '基地ID';
COMMENT ON COLUMN trace_staff.create_dept IS '部门ID';
COMMENT ON COLUMN trace_staff.user_id IS '用户ID';

-- ----------------------------
-- Records of trace_staff
-- ----------------------------
BEGIN;
INSERT INTO trace_staff (staff_id, staff_position, staff_name, staff_tel, staff_des, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag, tenant_id, base_id, create_dept, user_id) VALUES
    (1, '经理', '乔军', '18112857630', '非常的好', '', '0', 0, 1, '2023-08-02 21:10:29', 0, NULL, '2', 0, 0, 0, 0);
INSERT INTO trace_staff (staff_id, staff_position, staff_name, staff_tel, staff_des, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag, tenant_id, base_id, create_dept, user_id) VALUES
    (2, '1', '1', '1', '1', '', '0', 0, 1, '2023-08-02 21:12:34', 0, NULL, '2', 0, 0, 0, 0);
INSERT INTO trace_staff (staff_id, staff_position, staff_name, staff_tel, staff_des, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag, tenant_id, base_id, create_dept, user_id) VALUES
    (3, '1', '2', '3', '4', '', '0', 0, 1, '2023-08-02 21:13:45', 0, NULL, '2', 0, 0, 0, 0);
INSERT INTO trace_staff (staff_id, staff_position, staff_name, staff_tel, staff_des, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag, tenant_id, base_id, create_dept, user_id) VALUES
    (4, '1', '2', '3', '4', '', '2', 0, 1, '2023-08-02 21:14:50', 0, NULL, '2', 0, 0, 0, 0);
INSERT INTO trace_staff (staff_id, staff_position, staff_name, staff_tel, staff_des, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag, tenant_id, base_id, create_dept, user_id) VALUES
    (5, '业务经理', '乔军', '18112857630', '一次合作终身朋友', '', '0', 0, 1, '2023-08-04 14:18:38', 1, '2024-04-18 16:30:25', '0', 0, 0, 0, 0);
INSERT INTO trace_staff (staff_id, staff_position, staff_name, staff_tel, staff_des, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag, tenant_id, base_id, create_dept, user_id) VALUES
    (6, '测试', '1', '1', '1', '', '0', 0, 1, '2024-04-16 21:05:30', 1, '2024-04-18 16:30:47', '0', 0, 0, 0, 0);
INSERT INTO trace_staff (staff_id, staff_position, staff_name, staff_tel, staff_des, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag, tenant_id, base_id, create_dept, user_id) VALUES
    (7, '33', '33', '33', '333', '', '0', 0, 1, '2024-04-16 21:08:20', 1, '2024-04-18 16:30:49', '0', 0, 0, 0, 0);
INSERT INTO trace_staff (staff_id, staff_position, staff_name, staff_tel, staff_des, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag, tenant_id, base_id, create_dept, user_id) VALUES
    (8, '2', '2', '2', '2', '', '0', 0, 1, '2024-04-16 21:11:10', 1, '2024-04-18 16:38:52', '0', 0, 0, 0, 0);
INSERT INTO trace_staff (staff_id, staff_position, staff_name, staff_tel, staff_des, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag, tenant_id, base_id, create_dept, user_id) VALUES
    (9, '姚琼测试人员', '哈哈', '18112857630', '阿房东发', '', '0', 0, 10, '2024-08-22 13:16:09', 12, '2024-10-18 15:03:37', '0', 113, 101, 103, 10);
COMMIT;

-- ----------------------------
-- Table structure for trace_template
-- ----------------------------
DROP TABLE IF EXISTS trace_template;

CREATE TABLE trace_template
(
    template_id   BIGINT        NOT NULL DEFAULT nextval('trace_template_template_id_seq'::regclass),
    template_name VARCHAR(100)  NOT NULL DEFAULT '',
    template_json JSONB,
    remark        VARCHAR(2000) NOT NULL DEFAULT '',
    status        CHAR(1)       NOT NULL DEFAULT '0',
    order_num     INTEGER       NOT NULL DEFAULT 0,
    create_by     BIGINT        NOT NULL DEFAULT 0,
    create_time   TIMESTAMP,
    update_by     BIGINT                 DEFAULT 0,
    update_time   TIMESTAMP,
    del_flag      CHAR(1)       NOT NULL DEFAULT '0',
    tenant_id     BIGINT        NOT NULL DEFAULT 0,
    base_id       BIGINT        NOT NULL DEFAULT 0,
    create_dept        int8,
    user_id       BIGINT        NOT NULL DEFAULT 0,
    PRIMARY KEY (template_id)
);


-- 创建序列用于自动递增
CREATE SEQUENCE trace_template_template_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

-- 添加注释
COMMENT ON TABLE trace_template IS '溯源模版表';
COMMENT ON COLUMN trace_template.template_id IS '模版ID';
COMMENT ON COLUMN trace_template.template_name IS '模版名称';
COMMENT ON COLUMN trace_template.template_json IS '模版JSON';
COMMENT ON COLUMN trace_template.remark IS '备注';
COMMENT ON COLUMN trace_template.status IS '状态（0可用 2不可用）';
COMMENT ON COLUMN trace_template.order_num IS '排序';
COMMENT ON COLUMN trace_template.create_by IS '创建者ID';
COMMENT ON COLUMN trace_template.create_time IS '创建时间';
COMMENT ON COLUMN trace_template.update_by IS '修改人ID';
COMMENT ON COLUMN trace_template.update_time IS '修改时间';
COMMENT ON COLUMN trace_template.del_flag IS '删除标志（0代表存在 2代表删除）';
COMMENT ON COLUMN trace_template.tenant_id IS '租户ID';
COMMENT ON COLUMN trace_template.base_id IS '基地ID';
COMMENT ON COLUMN trace_template.create_dept IS '部门ID';
COMMENT ON COLUMN trace_template.user_id IS '用户ID';

-- ----------------------------
-- Records of trace_template
-- ----------------------------
BEGIN;
INSERT INTO trace_template (template_id, template_name, template_json, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag, tenant_id, base_id, create_dept, user_id) VALUES
    (3, '页面模版1', '[{"type": "info", "title": "乔军标题", "backgroundColor": "rgba(255, 255, 255, 1)"}, {"data": {"text": "已经溯源#次"}, "type": "traceTime", "options": {}}, {"data": [{"remark": "12367呃呃呃呃444", "taskName": "播种", "taskImage": "/profile/iot/1/2023-1009-161451.png", "actualStart": "2024-04-30", "actualFinish": "2024-04-30", "taskHeadName": "乔军"}, {"form": {}, "remark": "施肥", "taskName": "施肥", "taskImage": "/profile/iot/1/2024-0418-111244.png", "actualStart": "2024-04-18", "actualFinish": "2024-04-26", "taskHeadName": "乔军"}], "type": "plantProgress", "options": {}}, {"data": {"remark": "皮薄，甜", "sellproId": 14, "sellproImg": "/profile/iot/1/2023-0809-100257.png", "sellproArea": "盐城东台", "sellproName": "黑金王炸", "sellproGuige": "盒", "sellproWeight": "22KG"}, "type": "productInfo", "options": {}}, {"data": [{"url": "/profile/iot/1/2024-0428-113742.png", "form": {}, "link": "", "name": "22333.png"}, {"url": "/profile/iot/1/2024-0428-113746.png", "form": {}, "link": "", "name": "22333.png"}, {"url": "/profile/iot/1/2024-0428-113838.png", "form": {}, "link": "", "name": "22333.png"}], "type": "quality", "options": {}}, {"data": {"name": "456", "position": "123"}, "type": "map", "options": {}}, {"data": [{"url": "/profile/iot/1/2024-0418-134910.png", "name": "333", "color": "#E75050", "value": "444"}, {"url": "/profile/iot/1/2024-0418-134842.png", "name": "11", "color": "#ED6262", "value": "33"}], "type": "plantEnv", "options": {}}, {"data": [{"staffDes": "2", "staffTel": "2", "staffName": "2", "staffPosition": "2"}, {"staffDes": "一次合作终身朋友", "staffTel": "18112857630", "staffName": "乔军", "staffPosition": "业务经理"}, {"staffDes": "一次合作终身朋友", "staffTel": "18112857630", "staffName": "乔军", "staffPosition": "业务经理"}], "type": "staff", "options": {}}, {"data": [{"shopImg": "/profile/iot/1/2023-0802-174630.png", "shopTel": "18112857630", "shopUrl": "https://item.taobao.com/item.htm?id=712366130554&ali_refid=a3_430673_1006:1125303001:N:emtiAWsF8%2Bzhhxaiwzc0Aw%3D%3D:1d8c5875b3f9dba8210ac36019832038&ali_trackid=162_1d8c5875b3f9dba8210ac36019832038&spm=a2e0b.20350158.31919782.2", "shopName": "盐城开发区店", "shopType": "1", "shopAddress": "盐城市开发区", "shopContacts": "乔军"}], "type": "shop", "options": {}}, {"data": [{"url": "/profile/iot/1/2024-0418-143904.png", "link": "", "name": "123.png"}], "type": "brand", "options": {}}]'::jsonb, '2', '0', 0, 1, '2024-04-14 16:27:21', 1, '2024-10-15 15:49:28', '0', 0, 0, 0, 0);
INSERT INTO trace_template (template_id, template_name, template_json, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag, tenant_id, base_id, create_dept, user_id) VALUES
    (4, '页面模版2', '[{"type": "info", "title": "乔军标题", "backgroundColor": "rgba(255, 255, 255, 1)"}, {"data": {"text": "核验次数", "times": ""}, "type": "traceTime", "options": {}}, {"data": [{"remark": "12367呃呃呃呃444", "taskName": "播种", "taskImage": "/profile/iot/1/2023-1009-161451.png", "actualStart": "2024-04-30", "actualFinish": "2024-04-30", "taskHeadName": "乔军"}, {"form": {}, "remark": "施肥", "taskName": "施肥", "taskImage": "/profile/iot/1/2024-0418-111244.png", "actualStart": "2024-04-18", "actualFinish": "2024-04-26", "taskHeadName": "乔军"}, {"remark": "e记得记得就好的好的基督教xx把bv你了哈哈哈", "taskName": "播种1", "taskImage": "/profile/upload/2024/04/23/8d0f2ca0-3066-4fd4-8f9b-57d9018b2aed.jpg", "actualStart": "2024-04-26", "actualFinish": "2024-04-26", "taskHeadName": "张三"}, {"remark": "e记得记得就好的好的基督教xx把bv你了哈哈哈", "taskName": "播种1", "taskImage": "/profile/upload/2024/04/23/8d0f2ca0-3066-4fd4-8f9b-57d9018b2aed.jpg", "actualStart": "2024-04-26", "actualFinish": "2024-04-26", "taskHeadName": "张三"}, {"remark": "e记得记得就好的好的基督教xx把bv你了哈哈哈", "taskName": "播种1", "taskImage": "/profile/upload/2024/04/23/8d0f2ca0-3066-4fd4-8f9b-57d9018b2aed.jpg", "actualStart": "2024-04-26", "actualFinish": "2024-04-26", "taskHeadName": "张三"}], "type": "plantProgress", "options": {}}, {"data": {"remark": "品种为日本进口，非常的好吃", "sellproId": 12, "sellproImg": "/profile/iot/1/2023-0809-100039.png", "sellproArea": "江苏盐城尚庄", "sellproName": "番茄", "sellproGuige": "10个", "sellproWeight": "10KG"}, "type": "productInfo", "options": {}}, {"data": {"name": "ddddd", "address": "盐城经济技术开发去希望达到5号", "position": "120.16,33.35"}, "type": "map", "options": {}}, {"data": [{"url": "/profile/iot/1/2024-0428-113947.png", "form": {}, "link": "http://baidu.com", "name": "22333.png"}, {"url": "/profile/iot/1/2024-0428-113950.png", "form": {}, "link": "http://baidu.com", "name": "22333.png"}, {"url": "/profile/iot/1/2024-0428-114004.png", "form": {}, "link": "http://baidu.com", "name": "22333.png"}], "type": "quality", "options": {}}, {"data": [{"url": "/profile/iot/1/2024-0428-135502.png", "name": "压力", "unit": "℃", "color": "#E75050", "value": "32"}, {"url": "/profile/iot/1/2024-0428-135506.png", "name": "湿度", "unit": "℃", "color": "#ED6262", "value": "33"}, {"url": "/profile/iot/1/2024-0428-135514.png", "name": "光照", "unit": "us", "color": "", "value": "30"}, {"url": "/profile/iot/1/2024-0428-135520.png", "name": "湿度", "unit": "%", "color": "", "value": "100"}, {"url": "/profile/iot/1/2024-0428-135533.png", "name": "温度", "unit": "ppt", "color": "", "value": "32"}], "type": "plantEnv", "options": {}}, {"data": [{"staffDes": "一次合作终身朋友", "staffTel": "18112857630", "staffName": "乔军", "staffPosition": "业务经理"}, {"staffDes": "一次合作终身朋友", "staffTel": "18112857630", "staffName": "乔军", "staffPosition": "业务经理"}], "type": "staff", "options": {}}, {"data": [{"shopImg": "/profile/iot/1/2023-0802-174630.png", "shopTel": "18112857630", "shopUrl": "https://item.taobao.com/item.htm?id=712366130554&ali_refid=a3_430673_1006:1125303001:N:emtiAWsF8%2Bzhhxaiwzc0Aw%3D%3D:1d8c5875b3f9dba8210ac36019832038&ali_trackid=162_1d8c5875b3f9dba8210ac36019832038&spm=a2e0b.20350158.31919782.2", "shopName": "盐城开发区店", "shopType": "1", "shopAddress": "盐城市开发区", "shopContacts": "乔军"}], "type": "shop", "options": {}}, {"data": [{"url": "/profile/iot/1/2024-0428-143521.jpg", "link": "http://baidu.com", "name": "7.jpg"}], "type": "brand", "options": {}}]'::jsonb, '123', '0', 0, 1, '2024-04-15 10:14:36', 1, '2024-04-30 14:27:14', '0', 0, 0, 0, 0);
INSERT INTO trace_template (template_id, template_name, template_json, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag, tenant_id, base_id, create_dept, user_id) VALUES
    (5, '页面模版3', '[{"type": "info", "title": "", "backgroundColor": ""}, {"data": [{"remark": "12367呃呃呃呃444", "taskName": "播种", "taskImage": "/profile/iot/1/2023-1009-161451.png", "actualStart": null, "actualFinish": null, "taskHeadName": null}], "type": "plantProgress", "options": {}}]'::jsonb, '用于西瓜', '0', 0, 1, '2024-04-30 14:32:28', 1, '2024-04-30 15:57:08', '0', 0, 0, 0, 0);
INSERT INTO trace_template (template_id, template_name, template_json, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag, tenant_id, base_id, create_dept, user_id) VALUES
    (6, '姚琼测试模版', '[{"type": "info", "title": "", "backgroundColor": ""}, {"data": {"text": "已经被溯源", "times": ""}, "type": "traceTime", "options": {}}, {"data": {}, "type": "map", "options": {}}]'::jsonb, '无', '0', 0, 10, '2024-08-22 11:23:57', 12, '2024-10-18 14:59:17', '0', 113, 101, 103, 10);
INSERT INTO trace_template (template_id, template_name, template_json, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag, tenant_id, base_id, create_dept, user_id) VALUES
    (7, '玫瑰花溯源', '[{"type": "info", "title": "", "backgroundColor": ""}, {"data": {}, "type": "map", "options": {}}]'::jsonb, '玫瑰花溯源', '0', 0, 15, '2024-09-02 10:28:54', 15, '2024-09-02 10:29:04', '0', 113, 110, 110, 15);
COMMIT;


-- ----------------------------
-- Table structure for trace_version
-- ----------------------------
DROP TABLE IF EXISTS trace_version;

CREATE TABLE trace_version
(
    version_id  BIGINT        NOT NULL DEFAULT nextval('trace_version_version_id_seq'::regclass),
    sellpro_id  BIGINT        NOT NULL DEFAULT 0,
    code_range  VARCHAR(250)  NOT NULL DEFAULT '',
    remark      VARCHAR(2000) NOT NULL DEFAULT '',
    status      CHAR(1)       NOT NULL DEFAULT '2',
    order_num   INTEGER       NOT NULL DEFAULT 0,
    create_by   BIGINT        NOT NULL DEFAULT 0,
    create_time TIMESTAMP,
    update_by   BIGINT                 DEFAULT 0,
    update_time TIMESTAMP,
    del_flag    CHAR(1)       NOT NULL DEFAULT '0',
    PRIMARY KEY (version_id)
);


-- 创建序列用于自动递增
CREATE SEQUENCE trace_version_version_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

-- 添加注释
COMMENT ON TABLE trace_version IS '溯源版本表';
COMMENT ON COLUMN trace_version.version_id IS '溯源版本ID';
COMMENT ON COLUMN trace_version.sellpro_id IS '产品ID';
COMMENT ON COLUMN trace_version.code_range IS '溯源版本编号';
COMMENT ON COLUMN trace_version.remark IS '备注';
COMMENT ON COLUMN trace_version.status IS '状态 1可用 2不可用 trace_status';
COMMENT ON COLUMN trace_version.order_num IS '排序';
COMMENT ON COLUMN trace_version.create_by IS '创建者ID';
COMMENT ON COLUMN trace_version.create_time IS '创建时间';
COMMENT ON COLUMN trace_version.update_by IS '修改人ID';
COMMENT ON COLUMN trace_version.update_time IS '修改时间';
COMMENT ON COLUMN trace_version.del_flag IS '删除标志（0代表存在 2代表删除）';

-- ----------------------------
-- Records of trace_version
-- ----------------------------
BEGIN;
INSERT INTO trace_version (version_id, sellpro_id, code_range, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag) VALUES
    (1, 12, 'frog20240419205441000001-frog20240419205441000005', '', '0', 0, 1, '2024-04-19 20:54:42', 0, NULL, '0');
INSERT INTO trace_version (version_id, sellpro_id, code_range, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag) VALUES
    (2, 14, 'frog20240419205446000001-frog20240419205446000015', '', '0', 0, 1, '2024-04-19 20:54:47', 0, NULL, '0');
INSERT INTO trace_version (version_id, sellpro_id, code_range, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag) VALUES
    (3, 14, 'frog20240419210341000001-frog20240419210341000006', '', '0', 0, 1, '2024-04-19 21:03:41', 0, NULL, '0');
INSERT INTO trace_version (version_id, sellpro_id, code_range, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag) VALUES
    (4, 12, 'frog20240420141955000001-frog20240420141955000100', '', '0', 0, 1, '2024-04-20 14:19:55', 0, NULL, '0');
INSERT INTO trace_version (version_id, sellpro_id, code_range, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag) VALUES
    (5, 12, 'frog20240420142152000001-frog20240420142152010000', '', '0', 0, 1, '2024-04-20 14:21:52', 0, NULL, '0');
INSERT INTO trace_version (version_id, sellpro_id, code_range, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag) VALUES
    (6, 12, 'frog20240420142712000001-frog20240420142712001000', '', '0', 0, 1, '2024-04-20 14:27:13', 0, NULL, '0');
INSERT INTO trace_version (version_id, sellpro_id, code_range, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag) VALUES
    (7, 12, 'frog20240420223824000001-frog20240420223824001000', '', '0', 0, 1, '2024-04-20 22:38:25', 0, NULL, '0');
INSERT INTO trace_version (version_id, sellpro_id, code_range, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag) VALUES
    (8, 12, 'frog20240429231309000001-frog20240429231309000011', '', '0', 0, 1, '2024-04-29 23:13:10', 0, NULL, '0');
INSERT INTO trace_version (version_id, sellpro_id, code_range, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag) VALUES
    (9, 12, 'frog20240429231448000001-frog20240429231448000013', '', '0', 0, 1, '2024-04-29 23:14:49', 0, NULL, '0');
INSERT INTO trace_version (version_id, sellpro_id, code_range, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag) VALUES
    (10, 12, 'frog20240429231816000001-frog20240429231816000017', '', '0', 0, 1, '2024-04-29 23:18:17', 0, NULL, '0');
INSERT INTO trace_version (version_id, sellpro_id, code_range, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag) VALUES
    (11, 17, 'frog20240822104627000001-frog20240822104627000003', '', '0', 0, 10, '2024-08-22 10:46:28', 0, NULL, '0');
INSERT INTO trace_version (version_id, sellpro_id, code_range, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag) VALUES
    (12, 18, 'frog20240902103429000001-frog20240902103429000002', '', '0', 0, 15, '2024-09-02 10:34:30', 0, NULL, '0');
INSERT INTO trace_version (version_id, sellpro_id, code_range, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag) VALUES
    (13, 18, 'frog20240902103759000001-frog20240902103759000002', '', '0', 0, 1, '2024-09-02 10:38:00', 0, NULL, '0');
INSERT INTO trace_version (version_id, sellpro_id, code_range, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag) VALUES
    (14, 17, 'frog20241018145636000001-frog20241018145636000002', '', '0', 0, 12, '2024-10-18 14:56:37', 0, NULL, '0');
COMMIT;
